package com.test.service;


import com.test.dao.DishDao;
import com.test.domain.Dish;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;

@Component
public class DishService {

    private final DishDao dishDao;

    @Autowired

    public DishService(DishDao dishDao) {
        this.dishDao = dishDao;
    }

    public void insertDish(Dish dish) {
        dishDao.insertDish(dish);
    }

    //商家获取菜品
    public List<Dish> getDishList(String phoneNumber){
        return dishDao.getDishListByPhoneNumber(phoneNumber);
    }

    //商家更新菜品名
    public void updateDishName(String dishNumber,String dishName){
        dishDao.updateDishName(dishNumber,dishName);
    }

    public void updateDishDescription(String dishNumber, String dishDescription) {
        dishDao.updateDishDescription(dishNumber,dishDescription);
    }

    public void updateDishPrice(String dishNumber, BigDecimal dishPrice) {
        dishDao.updateDishPrice(dishNumber,dishPrice);
    }


    public void updateIsSale(String dishNumber, int isSale) {
        dishDao.updateIsSale(dishNumber,isSale);
    }

    public void deleteDish(String dishNumber){
        dishDao.deleteDishByDishNumber(dishNumber);
    }

}
